#include<bits/stdc++.h>
using namespace std;
int main(){
	freopen("arena.in","r",stdin);
	freopen("arena.out","w",stdout);
	int n,m;
	cin>>n>>m;
	int a[100005];
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	int ans=0;
	for(int i=1;i<=m;i++){
		int c;
		cin>>c;
		if(c==1){
			ans++;
			break;
		}
		int num=1;
		
		int q;
		for(q=1;q>=0;q++){
			num*=2;
			if(num>=c){
				ans+=num-c;
				break;
			}
		}
		for(int j=1;j<=c;j++){
			if(a[j]>=q)ans++;
		}
	}
	cout<<ans;
	return 0;
}
